package com.scaffold.springmvc.action;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 通过路径/xx.vm预览页面
 * 在测试配置文件(如config.local.xml)中注入
 * @author wangjg
 *
 */
@Controller
public class PreviewAction {

	public PreviewAction() {
	}
	
	private String prefix = "";
	
	@RequestMapping(value="/**/*.vm")
    public String view(HttpServletRequest request) {
        String result = request.getServletPath();
        return this.prefix+result;
    }
	
	@RequestMapping(value="/hello/{path1}.xhtml")
		public String view(@PathVariable String path1) {
		String result = path1+".vm";
		return result;
	}
	
	public String getPrefix() {
		return prefix;
	}

	public void setPrefix(String prefix) {
		this.prefix = prefix;
	}
}
